<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>后台管理系统</title>
	    <meta name="author" content="BaiYY"/>
	    <meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	    <meta name="renderer" content="webkit">
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/pages.css"/>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/time.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/pages.js"></script>
	</head>
		<body>
		
			<!--右边侧栏开始-->
			<div class="right-sidebar"style="max-width: 1200px;">
				<div class="input-group col-md-12" style="margin:10px auto 5px;">
				  <input type="number" min="1" class="form-control" placeholder="请输入想查看近多少小时内的玩家详情" name="hours" id="hours">
				  <span class="input-group-addon" id="cbtn">查&emsp;询</span>
				</div>
				<section class="table-responsive">
					<table class="table" style="border: 1px solid #ddd;">
						<thead>
							<tr>
								<th>游戏ID</th>
								<th>微信昵称</th>
								<th>{:L(GAME_RESOURCE)}张数</th>
								<th>金币数量</th>
								<th>创建时间</th>
							</tr>
						</thead>
						<tbody id="dataList"></tbody>
					</table>
				</section>
				<ul class="page" id="page" style="width: 100%;overflow: hidden;"></ul>
			</div>
		<script type="text/javascript">
			$("#hours").blur(function(){
				var hours = $(this).val();
				if(parseInt(hours) > 1000) {
					alert("查询的最大小时数为1000");
					window.location.href="{:U('Admin/Main/playerList')}";
					return false;
				}
			});
			
			$("#cbtn").on("click",function(){
				var hours = $.trim($('#hours').val());
				if(parseInt(hours) <= 0 ) {
					alert("请输入正确的小时数！");
					window.location.href="{:U('Admin/Main/playerList')}";
					return false;
				}
				$.ajax({
					type:"post",
					url:"{:U('Admin/Main/playerDetail')}",
					dataType:"json",
					data:{'hours':hours},
					success:function(datas) {
//						console.log(datas);

						if(datas != 'error' && datas) {
							datas=datas.reverse();
//							console.log(datas);
							options={
								"id":"page",//显示页码的元素
								"data":datas,//显示数据
							    "maxshowpageitem":2,//最多显示的页码个数
							    "pagelistcount":10,//每页显示数据个数
							    "callBack":function(data){
							    	var str = "";
									for(var i=0;i<data.length;i++) {
										if(!data[i].status.coin) {
											data[i].status.coin = 0;
										}
										var time = new Date(data[i].info.createTime*1000);
										str +="<tr><td>"+data[i]._id+"</td><td>"+data[i].info.name+"</td><td>"+data[i].status.card+"</td><td>"+data[i].status.coin+"</td><td>"+time.toLocaleString()+"</td></tr>";
									}
									$("#dataList").html(str);
						    	}
						   }
						   page.init(datas.length,1,options);
						}else{
							alert("抱歉！暂时没有查到任何数据!");
							window.location.href="{:U('Admin/Main/playerList')}";
						}
					}
				});
			});
		</script>
		</body>
	</html>

